'''
Created on Apr 2, 2013

@author: kevinbauer
'''

import numpy as np

class NeuralNetwork(object):

    def __init__(self, a):
        self.LR = 0.05 # LR is the learning rate.
        self.STOPPER = 100 # When the error is less than this value, we stop the recurrence.
        self.attack = a
        self.attackWeights = np.zeros_like(self.attack[0,:], np.float)

    def hypothesize(self):
        
        COUNTER = 0
        STOP = 30
        
        while COUNTER > STOP:
            
            minuend = np.float
            minuend = 1
            
            err = [] # Attack errors
            
            for a in np.nditer(self.attack, op_flags=['readwrite']):                
                for w in np.nditer(self.attackWeights, op_flags=['readwrite']):
                    #print "Weight ", w
                    #print "Value ", a
                    error = minuend - w * a
                    #print "Error ", error
                    err.append(error) 
                    w[...] = w + self.LR * error * a
        
            # Calculate the sum of squared errors.
            #ERROR = sum(err)
            
        return self.attackWeights
        